﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HHG.DBUtility;
using System.Data.SqlClient;
using System.Data;
using OnLineExam.BLL;
using OnLineExam.Model;
using HHG.Common;
using OnLineExam.Web.Services;

namespace OnLineExam.Web
{
	public partial class UserTest : BasePage
	{
		protected int singeCount = 1;
		public int examtime = 0;//考试时长
		protected int _allowExamCount = 0;
		protected int _hasExamCount = 0;
        protected int ScoreId { get; set; }
		protected void Page_Load(object sender, EventArgs e)
		{

			var paperId = Request.QueryString["PaperId"].GetInt();
			if (!Page.IsPostBack)
			{
				string userId = User.Identity.Name;
				if (Session["PaperID"] == null)
				{
					Response.Redirect("studentindex.aspx");
				}

				string userName = UserManager.GetUserName(userId);

				PaperManager bll = new PaperManager();

				Paper p = bll.GetModel(paperId);

				//Paper p = PaperManager.GetItem(PaperID);

				//考试时长的控制
				examtime = int.Parse(p.ExamTime);
				//this.Timer1.Interval = int.Parse(p.Examtime1) * 60 * 1000;
				//this.Timer1.Enabled = true;

				int allwortextcount = p.allowExamNum;//允许考试次数

				var checkInfo = Extensions.PaperExtension.CheckIsAllowExam(userId, paperId);
				if (checkInfo.Result == false)
				{
					lblMessage.Text = checkInfo.Message;
					Response.Write(checkInfo.Message);
					Response.End();
					return;
				}

				var resultData = Extensions.PaperExtension.GetExamCount(userId, paperId, allwortextcount);
				_hasExamCount = resultData.hasCount;
				_allowExamCount = resultData.allwort;

				 

				Label i1 = (Label)Page.FindControl("labUser");
				i1.Text = userName;

				lblPaperName.Text = Session["PaperName"].ToString();
				//GetParperAll();

				#region 考试次数限制
				  
                using (var ctx=new Data.OnlineExamEntities())
                {
                    

                    var score=ctx.Score.Add(new Data.Score
                    {

                        PaperID = p.PaperID,
                        CourseID = 0,
                        DepID = 0,
                        ExamTime = DateTime.Now,
                        FillBlankProblemMark = 0,
                        JudgeProblemMark = 0,
                        MultiProblemMark = 0,
                        QuestionProblemMark = 0,
                        SingleProblemMark = 0,
                        UserID = userId,
                        UserScore = 0
                    });
                    ctx.SaveChanges();
                    ctx.UserTestInfo.Add(new Data.UserTestInfo
                    {

                        PaperID = p.PaperID,
                        Type = "进入考试",
                        TitleID = 0,
                        ExamTime = DateTime.Now,
                        Mark = 0,
                        UserAnswer = "0",
                        UserMark = 0,
                        UserID = userId,
                        ScoreId = score.ID
                    });
                    ctx.SaveChanges();
                   
                    ScoreId = score.ID;
                    hdScoreId.Value = ScoreId+"";

                }
				#endregion

				#region 随机获取
				hfDepID.Value = p.DepID + "";
				hfCourseID.Value = p.CourseID + "";

				//var p = PaperManager.GetItem(PaperID);
				this.lblPaperName.Text = p.PaperName;
				var probleminfo = p.ProblemInfo.Split(',');
				int single = int.Parse(probleminfo[0].Split(':')[1]);
				int multi = int.Parse(probleminfo[1].Split(':')[1]);
				int judge = int.Parse(probleminfo[2].Split(':')[1]);
				int fillblank = int.Parse(probleminfo[3].Split(':')[1]);
				int question = int.Parse(probleminfo[4].Split(':')[1]);

				if (single == 0)
					this.Panel1.Visible = false;

				if (multi == 0)
					this.Panel2.Visible = false;
				if (judge == 0)
					this.Panel3.Visible = false;
				if (fillblank == 0)
					this.Panel4.Visible = false;
				if (question == 0)
					this.Panel5.Visible = false;

				//随机抽题目
				//DataTable singledt = DbHelperSQL.ExecuteSql("select top " + single + " * from SingleProblem where ");


				//this.lbMulti.Text = probleminfo[1].Split(':')[2];
				//this.lbJudge.Text = probleminfo[2].Split(':')[2];
				//this.lbFillBlank.Text = probleminfo[3].Split(':')[2];
				//this.lbQuestion.Text = probleminfo[4].Split(':')[2];
				//分数
				this.labSingle.Text = probleminfo[0].Split(':')[2];
				this.lbMulti.Text = probleminfo[1].Split(':')[2];
				this.lbJudge.Text = probleminfo[2].Split(':')[2];
				this.lbFillBlank.Text = probleminfo[3].Split(':')[2];
				this.lbQuestion.Text = probleminfo[4].Split(':')[2];


				#region 获取试卷
				//题目数
				int singlenum = int.Parse(probleminfo[0].Split(':')[1]);
				int multinum = int.Parse(probleminfo[1].Split(':')[1]);
				int judgenum = int.Parse(probleminfo[2].Split(':')[1]);
				int fillblanknum = int.Parse(probleminfo[3].Split(':')[1]);
				int questionnum = int.Parse(probleminfo[4].Split(':')[1]);
				var sbll = new SingleSelectedManager();
				var sds = HHG.DBUtility.DbHelperSQL.Query("select top " + singlenum + " * from SingleProblem where   PaperID=" + p.PaperID + " order by newid()");

				var mbll = new SingleSelectedManager();
				var mds = HHG.DBUtility.DbHelperSQL.Query("select top " + multinum + " * from MultiProblem where   PaperID=" + p.PaperID + " order by newid()");

				var jbll = new SingleSelectedManager();
				var jds = HHG.DBUtility.DbHelperSQL.Query("select top " + judgenum + " * from JudgeProblem where   PaperID=" + p.PaperID + " order by newid()");

				var fbll = new SingleSelectedManager();
				var fds = HHG.DBUtility.DbHelperSQL.Query("select top " + fillblanknum + " * from FillBlankProblem where    PaperID=" + p.CourseID + " order by newid()");

				var qbll = new SingleSelectedManager();
				var qds = HHG.DBUtility.DbHelperSQL.Query("select top " + questionnum + " * from QuestionProblem where   PaperID=" + p.PaperID + " order by newid()");

				this.singleRep.DataSource = sds;
				this.singleRep.DataBind();

				this.rpMulti.DataSource = mds;
				this.rpMulti.DataBind();

				this.rpJudge.DataSource = jds;
				this.rpJudge.DataBind();

				foreach (DataRow item in fds.Tables[0].Rows)
				{
					var newitem = item["FrontTitle"].ToString();
					item["FrontTitle"] = newitem.Replace("_", "<input id=inputtitle name=inputtitle value='' />");
				}

				this.rpFillBlank.DataSource = fds;
				this.rpFillBlank.DataBind();

				this.rpQuestion.DataSource = qds;
				this.rpQuestion.DataBind();

				#endregion

				#endregion

				System.Timers.Timer timer = new System.Timers.Timer();
				timer.Enabled = false;
				timer.Interval = examtime * 60 * 1000;
				timer.Elapsed += Timer_Elapsed;
			}
			else
			{
				//this.NewMethod("");
			}
		}
        protected bool IsShow(object obj)
        {
            var str = obj.GetString();
            return string.IsNullOrWhiteSpace(str) == false;
             
        }

        protected string SetHtml(object obj) {
			var str = obj.GetString();
			if (string.IsNullOrWhiteSpace(str))
				return obj + "";
			System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^<p>");
			str=regex.Replace(str,"");

			regex = new System.Text.RegularExpressions.Regex("</p>$");
			str = regex.Replace(str, "");

			return str;

		}

		private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
		{
			//throw new NotImplementedException();
		}

		 

		protected void imgBtnSubmit_Click(object sender, ImageClickEventArgs e)
		{ 
			NewMethod("");

		}

		private void NewMethod(string type)
		{
			var allUserValues = new List<Models.UserAnswerSubmitModel>();
			try
			{
				var spList = new List<Data.SingleProblem>();
				var jpList = new List<Data.JudgeProblem>();
				var mpList = new List<Data.MultiProblem>();

				var paperid = Request.QueryString["PaperId"].GetInt();
				string userId = User.Identity.Name;

				//SetScore(paperid, userId);
				UserAnswerService userAnswerService = new UserAnswerService();

				
				allUserValues.AddRange(GetSingleUserAnswerSubmitModels());
				allUserValues.AddRange(GetMultiUserAnswerSubmitModels());
				allUserValues.AddRange(GetJudgeUserAnswerSubmitModels());

				allUserValues.AddRange(GetFillUserAnswerSubmitModels());
				allUserValues.AddRange(GetQustionUserAnswerSubmitModels());

				var score= userAnswerService.SubmitPaper(hdScoreId.Value.GetInt(), paperid, userId, allUserValues);
				if (score.ID > 0)
				{
					if (type == "time")
					{
						Response.Write("<script language=javascript>$(window).unbind('beforeunload');alert('试卷提交成功!');window.location.href='studentindex.aspx';</script>");
					}
					else
					{
						Response.Write("<script language=javascript>alert('试卷提交成功!');window.location.href='studentindex.aspx';</script>");
					}
				}
				else
				{
					Response.Write("<script language=javascript>$(window).unbind('beforeunload');alert('试卷提交失败!'); </script>");
 
				}

			}
			catch (Exception ex)
			{

				if (type == "time")
				{
					Response.Write("<script language=javascript>$(window).unbind('beforeunload');alert('试卷提交失败!');</script>");
				}
				else
				{
					Response.Write("<script language=javascript>alert('试卷提交失败!');</script>");
				}


                base.WriteLog(ex, "考试提交异常,用户作答("+ allUserValues.SerializeObject()+")"); 
			}
			

		}
		private void SetScore(int paperId,string userId) {
			 

			var sMark = labSingle.Text.GetInt();
			using (var ctx=new Data.OnlineExamEntities())
			{
				var paper = ctx.Paper.FirstOrDefault(s=>s.PaperID== paperId);
				var spList = ctx.SingleProblem.AsNoTracking().Where(s => s.PaperID == paperId).ToList();
				var mpList = ctx.MultiProblem.AsNoTracking().Where(s => s.PaperID == paperId).ToList();
				var jpList = ctx.JudgeProblem.AsNoTracking().Where(s => s.PaperID == paperId).ToList();
				var fbList = ctx.FillBlankProblem.AsNoTracking().Where(s => s.PaperID == paperId).ToList();

				var userAnswers = new List<Data.UserAnswer>();
				var tempUserAnswers=this.GetSPUserAnswers(paper.MarkInfo.First(s=>s.QuestionType==Data.Paper.GetQuestionType( Data.QuestionType.Single)).Mark, paperId, userId, spList);
				tempUserAnswers = tempUserAnswers ?? new List<Data.UserAnswer>();
				userAnswers.AddRange(tempUserAnswers);

				tempUserAnswers = this.GetMPUserAnswers(paper.MarkInfo.First(s => s.QuestionType == Data.Paper.GetQuestionType(Data.QuestionType.Multi)).Mark, paperId, userId, mpList);
				tempUserAnswers = tempUserAnswers ?? new List<Data.UserAnswer>();
				userAnswers.AddRange(tempUserAnswers);

				tempUserAnswers = this.GetJuUserAnswers(paper.MarkInfo.First(s => s.QuestionType == Data.Paper.GetQuestionType(Data.QuestionType.Judge)).Mark, paperId, userId, jpList);
				tempUserAnswers = tempUserAnswers ?? new List<Data.UserAnswer>();
				userAnswers.AddRange(tempUserAnswers);

				tempUserAnswers = this.GetFullUserAnswers(paper.MarkInfo.First(s => s.QuestionType == Data.Paper.GetQuestionType(Data.QuestionType.Fill)).Mark, paperId, userId, fbList);
				tempUserAnswers = tempUserAnswers ?? new List<Data.UserAnswer>();
				userAnswers.AddRange(tempUserAnswers);

				tempUserAnswers = this.GetQuestionUserAnswers(paper.MarkInfo.First(s => s.QuestionType == Data.Paper.GetQuestionType(Data.QuestionType.Qustion)).Mark, paperId, userId);
				tempUserAnswers = tempUserAnswers ?? new List<Data.UserAnswer>();
				userAnswers.AddRange(tempUserAnswers);

				var score = new Data.Score {
					CourseID = paper.CourseID,
					DepID = paper.DepID,
					ExamTime = DateTime.Now,
					FillBlankProblemMark = userAnswers.Where(s => s.Type == Data.Paper.GetQuestionType(Data.QuestionType.Fill)).Sum(s=>s.UserMark),
					 JudgeProblemMark = userAnswers.Where(s => s.Type == Data.Paper.GetQuestionType(Data.QuestionType.Judge)).Sum(s => s.UserMark),
					 MultiProblemMark = userAnswers.Where(s => s.Type == Data.Paper.GetQuestionType(Data.QuestionType.Multi)).Sum(s => s.UserMark),
					   QuestionProblemMark = userAnswers.Where(s => s.Type == Data.Paper.GetQuestionType(Data.QuestionType.Qustion)).Sum(s => s.UserMark),
					 SingleProblemMark = userAnswers.Where(s => s.Type == Data.Paper.GetQuestionType(Data.QuestionType.Single)).Sum(s => s.UserMark),
					  PaperID=paperId,
					   UserID=userId,
					     
				};
				score.UserScore = score.SingleProblemMark + score.MultiProblemMark + score.JudgeProblemMark + score.FillBlankProblemMark + score.QuestionProblemMark;

				var newScore=ctx.Score.Add(score);
				userAnswers.ForEach(s=> {
					s.ScoreID = newScore.ID;
				});
				ctx.UserAnswer.AddRange(userAnswers);

				ctx.SaveChanges();
				 
			}


		}

		#region 整理用户作答 20180516

		private List<Models.UserAnswerSubmitModel> GetSingleUserAnswerSubmitModels()
		{

			var re = new List<Models.UserAnswerSubmitModel>();


			foreach (RepeaterItem item in singleRep.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				string str = "";
				 

				if (((RadioButton)item.FindControl("rbA")).Checked)
				{
					str = "A";
				}
				else if (((RadioButton)item.FindControl("rbB")).Checked)
				{
					str = "B";
				}
				else if (((RadioButton)item.FindControl("rbC")).Checked)
				{
					str = "C";
				}
				else if (((RadioButton)item.FindControl("rbD")).Checked)
				{
					str = "D";
				}
				 

				var model = new Models.UserAnswerSubmitModel
				{
					ItemId = titleId,
					QuestionType = Data.QuestionType.Single,
					UserValue = str

				};
				re.Add(model);
			}
			return re;
		}

		private List<Models.UserAnswerSubmitModel> GetMultiUserAnswerSubmitModels()
		{

			var re = new List<Models.UserAnswerSubmitModel>();


			foreach (RepeaterItem item in rpMulti.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				string str = "";

				  GetUserValue(item.FindControl("CheckBox1"), ref str, "A");
				  GetUserValue(item.FindControl("CheckBox2"), ref str, "B");
				  GetUserValue(item.FindControl("CheckBox3"), ref str, "C");
				  GetUserValue(item.FindControl("CheckBox4"), ref str, "D");
				  GetUserValue(item.FindControl("CheckBox5"), ref str, "E");
				  GetUserValue(item.FindControl("CheckBox6"), ref str, "F");
				  GetUserValue(item.FindControl("CheckBox7"), ref str, "G"); 
				 

				var model = new Models.UserAnswerSubmitModel
				{
					ItemId = titleId,
					QuestionType = Data.QuestionType.Multi,
					UserValue = str

				};
				re.Add(model);
			}
			return re;
		}
		private  void GetUserValue(Control control  ,ref string value,string itemFlag) {
			if (control is CheckBox)
			{
				var checkBox = control.FindControl("CheckBox1") as CheckBox;
				checkBox = checkBox ?? new CheckBox { Checked = false };
				if (checkBox.Checked)
				{
					value += itemFlag;
				}
			}
			else if (control is RadioButton)
			{
				var checkBox = control.FindControl("CheckBox1") as RadioButton;
				checkBox = checkBox ?? new RadioButton { Checked = false };
				if (checkBox.Checked)
				{
					value += itemFlag;
				}

			}
			
		}

		private List<Models.UserAnswerSubmitModel> GetJudgeUserAnswerSubmitModels()
		{

			var re = new List<Models.UserAnswerSubmitModel>();


			foreach (RepeaterItem item in rpJudge.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				string str = "";

				 
				 
				if (((RadioButton)item.FindControl("rbA")).Checked)
				{
					str = "正确";
					 
				}
				else if (((RadioButton)item.FindControl("rbB")).Checked)
				{
					str = "错误";
					 
				}


				var model = new Models.UserAnswerSubmitModel
				{
					ItemId = titleId,
					QuestionType = Data.QuestionType.Judge,
					UserValue = str

				};
				re.Add(model);
			}
			return re;
		}

		private List<Models.UserAnswerSubmitModel> GetFillUserAnswerSubmitModels()
		{

			var re = new List<Models.UserAnswerSubmitModel>();


			foreach (RepeaterItem item in rpFillBlank.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				var str = Request.Form["inputtitle"];
				 

				var model = new Models.UserAnswerSubmitModel
				{
					ItemId = titleId,
					QuestionType = Data.QuestionType.Fill,
					UserValue = str 
				};
				re.Add(model);
			}
			return re;
		}

		private List<Models.UserAnswerSubmitModel> GetQustionUserAnswerSubmitModels()
		{

			var re = new List<Models.UserAnswerSubmitModel>();


			foreach (RepeaterItem item in rpQuestion.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				var str ="";

				if(item.FindControl("TextBox2")!=null)
					str = ((TextBox)item.FindControl("TextBox2")).Text.Trim();
				else
				{

				}

				var model = new Models.UserAnswerSubmitModel
				{
					ItemId = titleId,
					QuestionType = Data.QuestionType.Qustion,
					UserValue = str
				};
				re.Add(model);
			}
			return re;
		}


		#endregion



		#region 整理用户作答

		private List<Data.UserAnswer> GetSPUserAnswers(int mark, int paperId, string userId, List<Data.SingleProblem> list)
		{
			var re = new List<Data.UserAnswer>();

			foreach (RepeaterItem item in singleRep.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				string str = "";
				if (((RadioButton)item.FindControl("rbA")).Checked)
				{
					str = "A";
				}
				else if (((RadioButton)item.FindControl("rbB")).Checked)
				{
					str = "B";
				}
				else if (((RadioButton)item.FindControl("rbC")).Checked)
				{
					str = "C";
				}
				else if (((RadioButton)item.FindControl("rbD")).Checked)
				{
					str = "D";
				}
				//获取正确答案

				int usermark = list.Any(s => s.ID == titleId && s.Answer == str) ? mark : 0;

				var model = new Data.UserAnswer
				{
					ExamTime = DateTime.Now,
					Mark = mark,
					PaperID = paperId,
					UserID = userId,
					TitleID = titleId,
					Type = Data.Paper.GetQuestionType(Data.QuestionType.Single),
					UserMark = usermark,
					ScoreID = 0,
					UserAnswer1 = str

				};
				re.Add(model);
			}
			return re;
		}

		private List<Data.UserAnswer> GetMPUserAnswers(int mark, int paperId, string userId, List<Data.MultiProblem> list)
		{
			var re = new List<Data.UserAnswer>();

			foreach (RepeaterItem item in rpMulti.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				string str = "";
				if (((CheckBox)item.FindControl("CheckBox1")).Checked)
				{
					str += "A";
				}
				if (((CheckBox)item.FindControl("CheckBox2")).Checked)
				{
					str += "B";
				}
				if (((CheckBox)item.FindControl("CheckBox3")).Checked)
				{
					str += "C";
				}
				if (((CheckBox)item.FindControl("CheckBox4")).Checked)
				{
					str += "D";
				}
				if (((CheckBox)item.FindControl("CheckBox5")).Checked)
				{
					str += "E";
				}
				if (((CheckBox)item.FindControl("CheckBox6")).Checked)
				{
					str += "F";
				}
				if (((CheckBox)item.FindControl("CheckBox7")).Checked)
				{
					str += "G";
				}
				//获取正确答案

				int usermark = list.Any(s => s.ID == titleId && s.Answer == str) ? mark : 0;

				var model = new Data.UserAnswer
				{
					ExamTime = DateTime.Now,
					Mark = mark,
					PaperID = paperId,
					UserID = userId,
					TitleID = titleId,
					Type = Data.Paper.GetQuestionType(Data.QuestionType.Multi),
					UserMark = usermark,
					ScoreID = 0,
					UserAnswer1 = str

				};
				re.Add(model);
			}
			return re;
		}

		private List<Data.UserAnswer> GetJuUserAnswers(int mark, int paperId, string userId, List<Data.JudgeProblem> list)
		{
			var re = new List<Data.UserAnswer>();

			foreach (RepeaterItem item in rpJudge.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				int usermark = 0;

				string str = "";
				var userAnswer = false;
				if (((RadioButton)item.FindControl("rbA")).Checked)
				{
					str = "正确";
					userAnswer = true;
				}
				else if (((RadioButton)item.FindControl("rbB")).Checked)
				{
					str = "错误";
					userAnswer = false;
				}
				if (str.HasValue())
					usermark = list.Any(s => s.ID == titleId && s.Answer == userAnswer) ? mark : 0;


				var model = new Data.UserAnswer
				{
					ExamTime = DateTime.Now,
					Mark = mark,
					PaperID = paperId,
					UserID = userId,
					TitleID = titleId,
					Type = Data.Paper.GetQuestionType(Data.QuestionType.Judge),
					UserMark = usermark,
					ScoreID = 0,
					UserAnswer1 = str

				};
				re.Add(model);
			}
			return re;
		}

		private List<Data.UserAnswer> GetFullUserAnswers(int mark, int paperId, string userId, List<Data.FillBlankProblem> list)
		{
			var re = new List<Data.UserAnswer>();

			foreach (RepeaterItem item in rpFillBlank.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				string str = "";
				str = Request.Form["inputtitle"];
				//str = ((TextBox)item.FindControl("TextBox1")).Text.Trim();

				//获取正确答案
				int usermark = list.Any(s => s.ID == titleId && s.Answer == str) ? mark : 0;

				var model = new Data.UserAnswer
				{
					ExamTime = DateTime.Now,
					Mark = mark,
					PaperID = paperId,
					UserID = userId,
					TitleID = titleId,
					Type = Data.Paper.GetQuestionType(Data.QuestionType.Fill),
					UserMark = usermark,
					ScoreID = 0,
					UserAnswer1 = str

				};
				re.Add(model);
			}
			return re;
		}

		private List<Data.UserAnswer> GetQuestionUserAnswers(int mark, int paperId, string userId)
		{
			var re = new List<Data.UserAnswer>();

			foreach (RepeaterItem item in rpQuestion.Items)
			{
				HiddenField hfTitleId = item.FindControl("titleId") as HiddenField;
				var titleId = hfTitleId.Value.GetInt();
				string str = "";
				str = ((TextBox)item.FindControl("TextBox2")).Text.Trim();

				var model = new Data.UserAnswer
				{
					ExamTime = DateTime.Now,
					Mark = mark,
					PaperID = paperId,
					UserID = userId,
					TitleID = titleId,
					Type = Data.Paper.GetQuestionType(Data.QuestionType.Qustion),
					UserMark = 0,
					ScoreID = 0,
					UserAnswer1 = str

				};
				re.Add(model);
			}
			return re;
		}

		#endregion


		protected void Timer1_Tick(object sender, EventArgs e)
		{

			//NewMethod("time");
			//Response.Write("<script language=javascript>$(window).unbind('beforeunload');</script>");//$(window).unbind('beforeunload');
		}

		void test()
		{
		}
		 
	}
}